Skip to content

Vendor coding and cua templates under environments/ - #512

Draft
jdchawla29 wants to merge 2 commits into
mainfrom
jaideep/vendor-environment-templates
Draft

Vendor coding and cua templates under environments/#512
jdchawla29 wants to merge 2 commits into
mainfrom
jaideep/vendor-environment-templates

Conversation

@jdchawla29

@jdchawla29 jdchawla29 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

What

Brings the coding template (the v6 rebuild with diff-based grading) and the cua template into the SDK repo under environments/, as canonical, in-repo examples of v6 environment authoring. Each is a standalone uv project with its own lockfile, Dockerfile, ruff config, and tests.

This is step 1 of making the SDK repo the source of truth for starter templates: follow-up PRs add a CI matrix that runs each template's tests against the SDK checkout (so SDK PRs that break a template fail at the PR boundary), release-gate oracle/null integrity runs, vendored hud init presets, and a mirror action back to the standalone template repos for the platform flow.

Repo integration

  • .gitignore: environments/ becomes environments/* + negations for the vendored templates, so untracked local environment checkouts stay ignored. Each template's own .gitignore re-includes its uv.lock (the root ignore is repo-wide).
  • pyproject.toml: environments/ added to hatch build excludes; root pyright/pytest scoping already excludes it, and ruff picks up each template's nested [tool.ruff].
  • Template hud pins aligned at >=0.6.11; standalone-repo tooling (pre-commit) dropped from dev extras.

Verification

  • coding: uv run pytest with the local SDK installed editable over the pin — 20 passed, 1 skipped (test_integration.py needs a built SWE-bench Pro instance image). test_local_rollout.py covers the full serve/connect/run/grade path (golden=1.0, baseline=0.0) against the checkout.
  • cua: 5 passed (grader composition; the desktop path needs the Linux image). Relocked after the pin bump.
  • Repo root: ruff check . and ruff format --check . clean.

Known follow-ups in the templates (deliberate, not drive-by)

  • coding: pytest is a runtime dep; fastmcp used but undeclared; a few dead-defensive branches and a test asserting a private helper.
  • cua: needs the same minimalism pass coding got — Dockerfile carries unused env vars and packages from the pre-v6 in-container tool stack, plus a weight pre-normalization block and misc branches worth cutting.

Note

Low Risk
Adds vendored example code under environments/ excluded from the main SDK package; no changes to core auth or runtime paths in this diff.

Overview
Vendors the full HUD v6 coding environment into environments/coding/ as a self-contained uv project (lockfile, Dockerfile, tests, ruff config), alongside the existing cua template. Root .gitignore now ignores environments/* but tracks environments/coding/ and environments/cua/.

The template implements diff-based grading with git history vaulting so agents never see answer-key refs: coding/repo.py snapshots, vaults .git, captures agent diffs, resets, and applies patches before hidden tests run. env.py wires an SSH workspace, three flavors — coding-task (generic bugs + hidden test refs), sdlc-task (mock GitHub MCP + PR branch grading), and SWE-bench Pro when instance assets are baked — plus sample rows in tasks.py / swe_tasks.py. Dockerfile.hud supports generic repo-clone images and instance overlays on prebuilt SWE images; swe_tasks.py fetches dataset rows and builds per-instance images.

Tests cover mock GitHub, SWE scoring/patch logic, hermetic local rollouts (golden vs baseline), optional Docker integration for built SWE images, and Dockerfile secret-handling smoke checks.

Reviewed by Cursor Bugbot for commit 76ffbed. Bugbot is set up for automated code reviews on this repo. Configure here.

HUD-2276

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ea60e77. Configure here.

Comment thread environments/coding/Dockerfile.hud
Comment thread environments/coding/coding/repo.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea60e77aee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread environments/coding/env.py
Comment thread environments/coding/env.py Outdated
Comment thread environments/coding/env.py Outdated
Comment thread environments/cua/env.py Outdated
Bring the coding (v6 rebuild) and cua starter templates into the SDK repo
as canonical examples of v6 environment authoring. Each is a standalone uv
project with its own lockfile, Dockerfile, and tests.

environments/* stays ignored except the vendored templates, so local
scratch checkouts are unaffected. The templates are excluded from the
built wheel/sdist; their nested ruff config keeps root lint isolated,
and root pyright/pytest scoping already excludes them.

Follow-ups: CI matrix running template tests against the local SDK,
release-gate integrity runs, vendored hud init presets, and mirroring
back to the standalone template repos.
@jdchawla29
jdchawla29 force-pushed the jaideep/vendor-environment-templates branch from ea60e77 to 76ffbed Compare July 31, 2026 02:49
@jdchawla29
jdchawla29 marked this pull request as ready for review July 31, 2026 02:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76ffbed2f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

env={"HOME": str(AGENT_HOME)},
track_files=settings.file_tracking_enabled,
shell_uid=AGENT_UID,
require_isolation=not is_root,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid requiring an unreleased Workspace keyword

When this standalone template is installed normally, its lockfile supplies HUD 0.6.11 and the declared range currently resolves at most to 0.6.12, but neither release accepts Workspace(require_isolation=...). Consequently _up() raises TypeError before serving any coding task; the tests only avoid this because they overlay the repository SDK checkout. Use only a released API or update and relock the dependency once the keyword is released.

Useful? React with 👍 / 👎.

Comment on lines +69 to +72
REMOTE_DIR = (
Path(os.environ.get("REMOTE_DIR", "/srv/git/project.git"))
if _explicit_repo
else _LOCAL_ROOT / f"remote-{os.getpid()}" / "project.git"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Expose the mock remote inside the local sandbox

For the documented non-root local SDLC run, isolation is now mandatory, but Workspace binds only REPO_DIR and gives the sandbox a private /tmp; REMOTE_DIR is a sibling host path under /tmp/hud-coding/.... The repository's origin therefore points to a path that does not exist inside the agent shell, so the required git push origin cannot succeed and every local sdlc-task is unshippable. Mount the remote read-write at the same guest path (or otherwise expose it without exposing the vault).

Useful? React with 👍 / 👎.

Comment on lines +158 to +160
async def reset_worktree(repo: Path, setup_commit: str) -> None:
await git(repo, "reset", "--hard", setup_commit)
await git(repo, "clean", "-fd")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore ignored artifacts before running graders

When a repository has ignored runtime inputs such as a virtualenv, generated configuration, or compiled output, an agent can modify those files and have the modifications affect grading without including them in its captured diff or pushed PR: git add -A omits ignored paths, while git clean -fd deliberately preserves them. Thus generic, SDLC, and SWE grading can pass because of state that is absent from the submitted patch; preserve a protected pre-agent copy of ignored setup artifacts and restore it before testing.

Useful? React with 👍 / 👎.

Comment on lines +157 to +158
task = asyncio.create_task(server.run_async(transport="http", host="127.0.0.1", port=port, show_banner=False))
return task, Capability.mcp(name="github", url=f"http://127.0.0.1:{port}/mcp")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for the GitHub MCP server before publishing it

If the harness discovers tools immediately after environment initialization, the capability can be used before server.run_async() has bound the selected port because serve() returns as soon as it schedules the task. That race produces a connection refusal and leaves SDLC runs without their required github_* tools; wait until the port accepts connections, as the other in-repo FastMCP environments do, before returning the capability.

Useful? React with 👍 / 👎.

@jdchawla29
jdchawla29 marked this pull request as draft July 31, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant